from collections import defaultdict

MODE = int(1e9) + 7
n, k = map(int, input().split())
nums = list(map(int, input().split()))
dp = [1] * n
nums_dict = defaultdict(list)
for i, s in enumerate(nums):
    nums_dict[s].append(i)
for i, v in enumerate(nums):
    if v - k not in nums_dict: continue
    for index in nums_dict[v - k]:
        if index >= i: continue
        dp[i] += (dp[index]) % MODE
print((sum(dp) - n) % MODE)
